<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>搜索框</title>
    <style>
        /*浮动布局*/
        .flex {
            display: flex;
        }

        /*换行*/
        .warp {
            flex-wrap: wrap;
        }

        /*每个模块均匀分布*/
        .space {
            justify-content: space-around;
        }

        /*左右两端分开布局*/
        .between {
            justify-content: space-between;
        }

        /*居中*/
        .center {
            justify-content: center;
        }

        /*绝对定位*/
        .absoulet {
            position: absolute;
        }

        /*相对定位*/
        .relative {
            position: relative;
        }

        /*固定定位*/
        .flexd {
            position: fixed;
        }

        /*收缩框体*/
        .padding-body {
            margin: 0;
            top: 0;
            left: 0;
            /* top: 10px; */
            width: 100%;
        }

        .flex_minddle {
            justify-content: center;
        }

        /*换行样式*/
        .flex_wrap {
            flex-wrap: wrap;
        }

        /*均匀分布样式模块*/
        .flex_around {
            justify-content: space-around;
        }

        /*左右两边分布*/
        .flex_between {
            justify-content: space-between;
        }

        .search_div2 {}

        /*搜索框父级样式*/
        .serach_body {
            border-radius: 12px;
            background-color: white;
            margin: 10px;
            box-shadow: 0 2px 3px 0 rgba(0, 0, 0, .05);
            line-height: 40px;
            text-align: center;
        }

        .search {
            border: 0px white;
            border: none;
            /*去掉边框*/
            outline: 0;
            /*移除浏览器的默认聚焦样式*/
            border-radius: 20px;
            margin-left: 20px;
            width: 400rpx;
        }

        .search_div1 {
            border: none;
            line-height: 40px;
            text-align: center;
        }


        /*分割线*/
        .line {
            width: 2px;
            height: 18px;
            font-size: 18px;
        }

        /*按钮样式*/
        .searchBtn {
            background: #4db46a;
            width: 196px;
            min-width: 118px;
            height: 40px;
            line-height: 60px;
            margin: 10px;
            font-size: 18px;
            color: #fff;
            -webkit-box-shadow: 0 2px 3px 0 rgba(0, 0, 0, .05);
            box-shadow: 0 2px 3px 0 rgba(0, 0, 0, .05);
            border-radius: 12px;
            cursor: pointer;
            display: -webkit-box;
            display: -ms-flexbox;
            display: flex;
            -webkit-box-align: center;
            -ms-flex-align: center;
            align-items: center;
            -webkit-box-pack: center;
            -ms-flex-pack: center;
            justify-content: center;
        }

        /*搜索框悬浮*/
        .search_float {}

        .search_float2 {
            top: 0px;
            z-index: 999;
            position: fixed;
            padding: 10px;
            line-height: 60px;
            display: flex;
            width: 100%;
            background-color: #e0eaf2;
            -webkit-animation: SlideDown .3s ease-in-out;
            animation: SlideDown .3s ease-in-out;
            -webkit-transition: background-color .4s ease-in-out;
            transition: background-color .4s ease-in-out;
        }

        .selectCity {
            width: 440px;
            /* height: 120px; */
            top: 267px;
            z-index: 999;
            position: absolute;
            font-weight: 400;
            font-size: 14px;
            color: #2dbb55;
            background-color: white;
            border-radius: 10px;
            padding: 10px 20px;
            box-shadow: 0 4px 4px 0 rgba(0, 0, 0, 0.1);
        }

        /*三角形*/
        .single {
            width: 0px;
            height: 0px;
            border: 10px solid #000;
            border-top-color: transparent;
            border-bottom-color: white;
            border-left-color: transparent;
            border-right-color: transparent;
            position: absolute;
            top: -16px;
            left: 20px;
        }

        /*城市*/
        .city>#city_arr {
            list-style: none;
        }


        #city_arr>ul {
            list-style: none;
            display: flex;
            justify-content: space-around;
        }

        .cloor_green {
            color: #2dbb55;
        }

        #city_arr>ul>li>a {
            color: black;
        }


        #city_arr>ul>li>a:hover {
            color: #60ca6e;
        }

        /*区域*/
        #localArea {
            display: flex;
            /* justify-content: space-around; */
        }

        #localArea>ul {
            list-style: none;
        }

        .margin-top {
            margin-top: 10px;
        }

        .margin-top2 {
            margin-top: 16px;
        }

        .margin-left {
            margin-left: 10%;
        }

        .margin-left2 {
            margin-left: 50px;
        }

        .margin-left1 {
            margin-left: 20px;
        }

        .margin-left_logo {
            margin-left: 10%;
        }

        .margin-left_select {
            margin-left: 7px;
        }
    </style>
</head>

<body>
    <div id="app">
        <!--搜索框2-->
        <div class="search_key2">
            <div class="center padding-body search_float2">
                <div class="flex">
                    <div class="serach_body flex">
                        <div class="search_div1 flex" @click="closeCity2">
                            <div style="width: 15px;height:18px;margin-left: 20px;margin-top: 2px;margin-right: -16px;">
                                <img src="../../img/logo/address.png" style="width: 15px;height:18px;margin-top: 10px;">
                            </div>
                            <input type="text" class="search" placeholder="请选择城市" v-model="city">
                            <div v-if="isShowFormXF" class="selectCity" style="top:70px">
                                <div class="single"></div>
                                <div class="flex_wrap">
                                    <div class="flex margin-left_select">
                                        江苏省
                                    </div>

                                    <div class="city flex flex_around margin-left_select">
                                        <div v-for="(item,i) in cityArr" id="city_arr">
                                            <div class="flex_wrap">
                                                <!--城市-->
                                                <div id="city_arr">
                                                    <ul>
                                                        <li>
                                                            <a href="javascript:void(0)"
                                                                @click="selectCity($event)">{{item.cityName}}</a>
                                                        </li>
                                                    </ul>
                                                </div>

                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="search_div2 flex">
                            <div class="block">
                                <el-date-picker
                                    style="border-top: none;border-bottom: none;border-radius: 0;margin-bottom: 2px;"
                                    v-model="date" type="daterange" range-separator="至" start-placeholder="入住日期"
                                    end-placeholder="退房日期">
                                </el-date-picker>
                            </div>
                        </div>

                        <div class="search_div1 flex">
                            <div style="width: 18px;height:16px;margin-left: 20px;margin-top: 2px;margin-right: -16px;">
                                <img src="../../img/logo/search.png" style="width: 18px;height:16px;margin-top: 10px;">
                            </div>
                            <input type="text" class="search" placeholder="关键字搜索">
                        </div>
                    </div>
                    <div class="" @click="searchBtn">
                        <div class="searchBtn" role="button"><i class="el-icon-search"></i>搜索酒店</div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--引用vue-->
    <script src="../../js/untils/vue.js"></script>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <!-- 引入组件库 -->
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
    <script>
        new Vue({
            el: "#app",
            data() {
                return {
                    // 城市数组
                    cityArr: [{
                            cityid: 1,
                            cityName: "南京",
                        },
                        {
                            cityid: 2,
                            cityName: "苏州",
                        },
                        {
                            cityid: 3,
                            cityName: "无锡",
                        },
                        {
                            cityid: 4,
                            cityName: "南通",
                        },
                        {
                            cityid: 5,
                            cityName: "常州",
                        },
                        {
                            cityid: 6,
                            cityName: "泰州",
                        },
                        {
                            cityid: 7,
                            cityName: "扬州",
                        },
                        {
                            cityid: 8,
                            cityName: "徐州",
                        },
                        {
                            cityid: 9,
                            cityName: "盐城",
                        },
                        {
                            cityid: 10,
                            cityName: "镇江",
                        },
                        {
                            cityid: 11,
                            cityName: "淮安",
                        },
                        {
                            cityid: 12,
                            cityName: "连云港",
                        },
                        {
                            cityid: 13,
                            cityName: "宿迁",
                        }
                    ],
                    date: '', // 日期
                    monitor: 0, // 页面滚动的高度(监听器)
                    city: '', // 搜索框选择的城市
                    isShowForm: false, // 是否展示城市选择框
                    isShowFormXF: false, // 悬浮框的城市选择框
                }
            },

            methods: {
                // 是否关闭城市选项
                closeCity() {
                    if (this.isShowForm) {
                        this.isShowForm = false;
                        this.monitor = window.pageYOffset;
                        console.log(this.monitor)
                    } else {
                        this.isShowForm = true;
                    }
                },

                // 是否关闭悬浮搜选框城市选项
                closeCity2() {
                    if (this.isShowFormXF) this.isShowFormXF = false;
                    else this.isShowFormXF = true;
                },

                // 选择城市
                selectCity(e) {
                    this.city = e.currentTarget.innerHTML
                    // console.log(e.currentTarget.innerHTML )
                },

            }
        })
    </script>
</body>
<!--顶部导航栏展示-->
<script type="text/javascript">
    $(function () {
        $(".search_key2").hide();
        $(window).scroll(function () {
            if ($(document).scrollTop() >= 230) {
                $(".search_key2").addClass(".search_key2").slideDown(); // 展示
            } else {
                $(".search_key2").hide(); // 隐藏
            }
        })
    })
</script>

</html>